<?php

use think\Facade\Route;
use think\Facade\Env;

Route::domain(Env::get('app.api_url'), function () {
    header("Access-Control-Allow-Origin: *");
    header('Access-Control-Allow-Methods: POST, PUT, GET, OPTIONS, DELETE, HEAD, PATCH');
    header("Access-Control-Allow-Headers: token,tokens,language, Origin, X-Requested-With, Content-Type, Accept");
    Route::miss(function () {
        $result = [
            'code' => 1,
            'msg'  => '接口不存在',
            'time' => time(),
            'data' => [],
        ];
        return json($result);
        exit();
    });
    Route::group('User', function () {
        Route::post('login', '/login'); //登录
        Route::rule('address', '/address'); //地址管理
        Route::post('address_del', '/address_del'); //地址管理
        Route::rule('cart', '/cart'); //地址管理
        Route::post('cart_del', '/cart_del'); //地址管理
        Route::post('putorder', '/putorder'); //提交订单
        Route::get('orderlist', '/orderlist'); //订单列表
        Route::get('getcoupon', '/getcoupon'); //订单列表
        Route::get('getorders', '/getorders'); //订单列表
        Route::get('orderdetail', '/orderdetail'); //订单列表
        Route::post('compent', '/compent'); //提交订单
        Route::get('goodscompent', '/goodscompent'); //提交订单
        Route::get('info', '/info'); //提交订单
        Route::post('orderstatus', '/orderstatus'); //提交订单
        Route::get('qrcode', '/qrcode'); //提交订单
        Route::post('buyuser', '/buyuser'); //提交订单
        Route::rule('bussiness_res', '/bussiness_res');
    })->prefix('User');
    Route::group('Other', function () {
        Route::get('getstreet', '/getstreet'); //获取地址
        Route::get('addressjson', '/addressjson'); //获取本地地址库
        Route::get('getclass', '/getclass'); //平台分类
        Route::get('getgoodsclass', '/getgoodsclass'); //首页热推
        Route::get('getsonclass', '/getsonclass'); //平台子分类
        Route::get('goodsdetail', '/goodsdetail'); //商品详情
        Route::get('banner', '/banner'); //轮播图
        Route::get('goodslist', '/goodslist'); //商品列表
        Route::get('business', '/business'); //商品列表
        Route::rule('oss', '/oss'); //商品列表
        Route::get('user_level', '/user_level'); //商品列表
        Route::rule('callback', '/callback'); //商品列表
        Route::rule('callback2', '/callback2'); //商品列表
        Route::get('street', '/street'); //提交订单
        Route::get('others', '/others'); //提交订单
        Route::get('convenclass', '/convenclass'); //提交订单
        Route::get('conven', '/conven'); //提交订单
        Route::get('getOpenId', '/getOpenId'); //提交订单
        Route::rule('getOpenIds', '/getOpenIds'); //提交订单
        Route::get('getPtDatas', '/getPtDatas'); //提交订单
    })->prefix('Other');
})->bind('api')->prefix('api');
